package com.lfx.concurrent.callable;

import java.util.concurrent.*;

/**
 * @author 李逢喜
 * create 2021/7/22
 */
public class MyCallableMain {


    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ThreadPoolExecutor executor=new ThreadPoolExecutor(5,5,1, TimeUnit.SECONDS,new ArrayBlockingQueue<>(10) ){
            @Override
            protected void afterExecute(Runnable r, Throwable t) {
                //处理call异常
                super.afterExecute(r, t);
                System.out.println("完了");
            }
        };
        Future<String> future = executor.submit(new MyCallable());
        String s = future.get();
        System.out.println(s);
        executor.shutdown();
        System.out.println("执行完成");
    }
}
